<style>
    .input-require {
        color: red;
    }
    .layui-form-select{
        color: #c2c2c2;
    }
    .layui-input{
        color: #c2c2c2;
        border-radius:4px;
    }
    .layui-form-select dl dd.layui-this{
        background-color: #FF6C60;
    }
    .layui-laydate .layui-this{
        background-color: #FF6C60!important;
    }

</style>

<div class="row">
    <div class="col-lg-12">
        <section class="panel">
            <header class="panel-heading">
                {$HandleName}
            </header>
            <div class="panel-body">
                <form id="form" class="layui-form form-horizontal tasi-form " method="get">
                    <div class="form-group" style="display: none">
                        <label class="col-sm-2 control-label">处理类型</label>
                        <div class="col-sm-10">
                            <input name="HandleType" type="text" class="form-control" value="{$HandleType}">
                        </div>
                    </div>
                    <div class="form-group" style="display: none">
                        <label class="col-sm-2 control-label">企业ID</label>
                        <div class="col-sm-10">
                            <input name="ID" type="text" class="form-control" value="{$Company['ID']}">
                        </div>
                    </div>
                    <div class="form-group">
                        <label class="col-sm-2 control-label">企业名称<span class="input-require">*</span></label>
                        <div class="col-sm-10">
                            <input name="Name" type="text" class="form-control" value="{$Company['Name']}" {$HandleType=='Edit'?'disable':''}>
                        </div>
                    </div>
                    <div class="form-group">
                        <label class="col-sm-2 control-label">企业商号</label>
                        <div class="col-sm-10">
                            <input name="Number" type="text" class="form-control" value="{$Company['Number']}">
                        </div>
                    </div>
                    <div class="form-group">
                        <label class="col-sm-2 control-label">企業類型</label>
                        <div class="col-sm-10">
                            <select name="Type" class="form-control m-bot15">
                                <?php
                                for($i=0; $i<7; $i++){
                                    $OptionName = '請選擇';
                                    switch($i){
                                        case 1: $OptionName = '股份有限公司';
                                            break;
                                        case 2: $OptionName = '有限公司';
                                            break;
                                        case 3: $OptionName = '合夥企業';
                                            break;
                                        case 4: $OptionName = '個人獨資企業';
                                            break;
                                        case 5: $OptionName = '個體工商戶';
                                            break;
                                        case 6: $OptionName = '其他';
                                            break;
                                        default:break;
                                    }


                                    $OptionStatus = '';
                                    if($i==$Company['Type']){
                                        $OptionStatus = 'selected';
                                    }
                                    echo "<option value='$i' $OptionStatus > $OptionName </option>";
                                }
                                ?>
                            </select>
                        </div>
                    </div>
                    <div class="form-group">
                        <label class="col-sm-2 control-label">企业规模</label>
                        <div class="col-sm-10">
                            <select name="Scale" class="form-control m-bot15">
                                <?php
                                for($i=0; $i<7; $i++){
                                    $OptionName = '请选择';
                                    switch($i){
                                        case 1: $OptionName = '1-50人';
                                            break;
                                        case 2: $OptionName = '51-100人';
                                            break;
                                        case 3: $OptionName = '101-300人';
                                            break;
                                        case 4: $OptionName = '300-500人';
                                            break;
                                        case 5: $OptionName = '501人以上';
                                            break;
                                        default:break;
                                    }


                                    $OptionStatus = '';
                                    if($i==$Company['Type']){
                                        $OptionStatus = 'selected';
                                    }
                                    echo "<option value='$i' $OptionStatus > $OptionName </option>";
                                }
                                ?>
                            </select>
                        </div>
                    </div>
                    <div class="form-group">
                        <label class="col-sm-2 control-label">经营模式</label>
                        <div class="col-sm-10">
                            <select name="Model" class="form-control m-bot15">
                                <?php
                                for($i=0; $i<5; $i++){
                                    $OptionName = '请选择';
                                    switch($i){
                                        case 1: $OptionName = '生产型';
                                            break;
                                        case 2: $OptionName = '供应型';
                                            break;
                                        case 3: $OptionName = '加工型';
                                            break;
                                        case 4: $OptionName = '代理型';
                                            break;
                                        default:break;
                                    }

                                    $OptionStatus = '';
                                    if($i==$Company['Model']){
                                        $OptionStatus = 'selected';
                                    }
                                    echo "<option value='$i' $OptionStatus > $OptionName </option>";
                                }
                                ?>
                            </select>
                        </div>
                    </div>
                    <div class="form-group">
                        <label class="col-sm-2 control-label">注册资本</label>

                            <div class="input-group col-sm-10">
                                <input  name="Capital" type="text" class="form-control" value="{$Company['Capital']}">
                                <span class="input-group-addon">万人民币</span>
                            </div>


                    </div>
                    <div class="form-group">
                        <label class="col-sm-2 control-label">成立日期</label>
                        <div class="col-sm-10">
                            <input id="TimeRegist" name="TimeRegist" type="text" class="form-control" value="{$Company['TimeRegist']}">
                        </div>
                    </div>
                    <div class="form-group">
                        <label class="col-sm-2 control-label">企业地址</label>
                        <div class="col-sm-10">
                            <input name="Address" type="text" class="form-control" value="{$Company['Address']}">
                        </div>
                    </div>
                    <div class="form-group">
                        <label class="col-sm-2 control-label">经营范围</label>
                        <div class="col-sm-10">
                            <textarea name="Scope" class="form-control" cols="60" rows="5">{$Company['Scope']}</textarea>
                        </div>
                    </div>

                    <?php if($HandleType == 'Edit'){ ?>

                    <div class="form-group">
                        <label class="col-sm-2 control-label">所属用户</label>
                        <div class="col-sm-10">
                            <select name="UserID" class="form-control m-bot15">

                                <?php
                                if($Company['UserID'] == '0') $OptionStatus = 'selected';
                                echo "<option value='0' $OptionStatus > 请选择 </option>";

                                for($i=0; $i<count($Users); $i++){
                                    $Value = $Users[$i];
                                    $UserID = $Value['ID'];
                                    $Nick = $Value['Nick'];

                                    $OptionStatus = '';
                                    if($UserID==$Company['UserID']){
                                        $OptionStatus = 'selected';
                                    }
                                    echo "<option value='$UserID' $OptionStatus > $Nick </option>";
                                }
                                ?>
                            </select>
                        </div>
                    </div>
                    <?php } ?>

                    <div class="form-group">
                        <label class="col-sm-2 control-label"></label>
                        <div class="col-sm-10">
                            <button class="btn btn-primary" lay-submit lay-filter="formSubmit">立即提交</button>
                            <button type="reset" class="btn btn-info">重置</button>
                        </div>
                    </div>
                </form>
            </div>
        </section>
    </div>
</div>

<script>
    layui.use(['form','laydate'], function () {
        var form = layui.form ,
            laydate = layui.laydate;
        laydate.render({
            elem:'#TimeRegist',
            type:'date'
        });
        form.on('submit(formSubmit)', function (data) {
            var fields = data.field;
            global.log('系统设定 - 提交数据', fields);
            global.post('/index.php/superadmin/Company_User/mb_SubmitCompany', fields, function (msg) {
                if (msg['code'] == ErrCode_Normal) {
                    layer.msg(msg['msg'], {
                        offset: '15px'
                        , icon: 1
                        , time: 1000
                    }, function () {
                        window.location.reload();
                    });
                } else mb_OnMessage(msg);
            });
            return false;
        });
    });
</script>